using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Leeder.Business;
using LogisticsAndongApi.Models;
using LogisticsAndongApi.Service;

namespace LogisticsAndongApi.Business
{
    /// <summary>
    /// 
    /// </summary>
   public class MaterialDirectionBLL : BaseBLL<MaterialDirectionModel, MaterialDirectionService>
   {
        public MaterialDirectionBLL()
        {
            Service = new MaterialDirectionService();
        }

        public List<MaterialDirectionModel> GetModelList()
        {
            var result = Service.Query(p => (!p.IsPhantom || p.IsPhantom == null));
            if (!result.IsSuccess)
            {
                LogObj.Error(result.Dsca);
                return new List<MaterialDirectionModel>();
            }
            return result.ActivedObj;
        }

        public List<MaterialDirectionModel> GetList(int typeId)
        {
            var result = Service.Query(p => (!p.IsPhantom || p.IsPhantom == null) && p.TypeId == typeId);
            if (!result.IsSuccess)
            {
                LogObj.Error(result.Dsca);
                return new List<MaterialDirectionModel>();
            }
            return result.ActivedObj;
        }

        public List<MaterialDirectionModel> GetList(string signalMark)
        {
            var result = Service.Query(p => (!p.IsPhantom || p.IsPhantom == null) && p.SignalMark.Equals(signalMark));
            if (!result.IsSuccess)
            {
                LogObj.Error(result.Dsca);
                return new List<MaterialDirectionModel>();
            }
            return result.ActivedObj;
        }

        public MaterialDirectionModel GetModel(long ID)
        {
            return Service.Query(p => (!p.IsPhantom || p.IsPhantom == null) && p.ID==ID).ActivedObj.FirstOrDefault();
        }


    }
}
